package com.itboye.sunsun.person.ui;

import com.itboye.sunsun.R;
import com.itboye.sunsun.application.App;
import com.itboye.sunsun.buy.ui.RedPacketActivity;
import com.itboye.sunsun.constants.NetPublicConstant;
import com.itboye.sunsun.constants.SPContants;
import com.itboye.sunsun.support.BaseActivity;
import com.itboye.sunsun.utils.SPUtils;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class EmsActivity extends BaseActivity implements OnClickListener {

	private ImageView back;
	private WebView webview;
	private String ordercode;
	String AppUrl = NetPublicConstant.secondUrl+"/Webview";
	String url;

	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.activity_emsactivity);
		
		Intent intent = getIntent();
		setStatusBarColor(R.color.top_blue);
		ordercode = intent.getStringExtra("ordercode");
		//Toast.makeText(App.ctx, ordercode, 0).show();
		webviewsettings();
	}

	@Override
	public void onClick(View v) {
		if (v.getId() == R.id.backrela) {
			this.finish();
		}

	}

	public void webviewsettings() {

		url = AppUrl + "/Express/viewOrder?order_code=" + ordercode;
		webview.getSettings().setJavaScriptEnabled(true);
		webview.loadUrl(url);
		WebSettings set = webview.getSettings();
		set.setDefaultTextEncodingName("utf-8");
		webview.setWebViewClient(new WebViewClient() {

			@Override
			public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
				// TODO Auto-generated method stub
				// super.onReceivedError(view, errorCode, description,
				// failingUrl);
				view.loadUrl("file:///android_asset/nonet.html");

			}

		});
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			if (webview.canGoBack()) {
				webview.goBack();
				return true;
			}

		}
		return super.onKeyDown(keyCode, event);
	}

}
